<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*" %>
<%@ page import="au.edu.unsw.editingtool.global.GlobalConstant" %>
<%@ page import="au.edu.unsw.editingtool.global.Util" %>
<br>
<br>
<br>
<hr>
<h2>DEBUG MODE</h2>
<BR>
<BR>
<fieldset>
<BR>
<BR>
<%-------------------------------%>
<%-- 1. PARAMATERS INFORMATION --%>
<%-------------------------------%>
<% 
	Enumeration paramNamesDebug = request.getParameterNames();
	if(paramNamesDebug.hasMoreElements())
	{
%>
<Table border=1>
<th colspan=2>Parameter information</th>	
<% 
	
		while(paramNamesDebug.hasMoreElements())
    	{
			String paramNameDebug = (String) paramNamesDebug.nextElement();
%>
	<TR><TD> <%=paramNameDebug %> </TD><TD> <%=(String) request.getHeader(paramNameDebug) %></TD></TR>
<%    
    	}
%>
</Table>
<%	} %>
<BR>
<BR>

<%----------------------------%>
<%-- 2. REQUEST INFORMATION --%>
<%----------------------------%>
<Table border=1>
	<th colspan=2>Request Object information</th>
	<TR><TD>request.getAuthType()</TD><TD> <%=(String) request.getAuthType() %></TD></TR>	
	<TR><TD>request.getMethod()</TD><TD> <%=(String) request.getMethod() %></TD></TR>
	<TR><TD>request.getPathInfo()</TD><TD> <%=(String) request.getPathInfo() %></TD></TR>
	<TR><TD>request.getPathTranslated()</TD><TD> <%=(String) request.getPathTranslated() %></TD></TR>
	<TR><TD>request.getContextPath()</TD><TD> <%=(String) request.getContextPath() %></TD></TR>
	<TR><TD>request.getQueryString()</TD><TD> <%=(String) request.getQueryString() %></TD></TR>
	<TR><TD>request.getRemoteUser()</TD><TD> <%=(String) request.getRemoteUser() %></TD></TR>	
	<TR><TD>request.getRequestedSessionId()</TD><TD> <%=(String) request.getRequestedSessionId() %></TD></TR>
	<TR><TD>request.getRequestURI()</TD><TD> <%=(String) request.getRequestURI() %></TD></TR>
	<TR><TD>request.getServletPath()</TD><TD> <%=(String) request.getServletPath() %></TD></TR>
	<TR><TD>request.getLocalAddr()</TD><TD> <%=(String) request.getLocalAddr() %></TD></TR>
	<TR><TD>request.getLocalName()</TD><TD> <%=(String) request.getLocalName() %></TD></TR>
	<TR><TD>request.getProtocol()</TD><TD> <%=(String) request.getProtocol() %></TD></TR>
	<TR><TD>request.getServerName()</TD><TD> <%=(String) request.getServerName() %></TD></TR>
	<TR><TD>request.getServerPort()</TD><TD> <%=request.getServerPort() %></TD></TR>
	<TR><TD>request.getServletPath()</TD><TD> <%=(String) request.getServletPath() %></TD></TR>	
	<TR><TD>request.isRequestedSessionIdValid()</TD><TD> <%=request.isRequestedSessionIdValid() %></TD></TR>
	<TR><TD>request.isRequestedSessionIdFromCookie()</TD><TD> <%=request.isRequestedSessionIdFromCookie() %></TD></TR>
	<TR><TD>request.isRequestedSessionIdFromURL()</TD><TD> <%=request.isRequestedSessionIdFromURL() %></TD></TR>
	<TR><TD>request.getQueryString()</TD><TD> <%=request.getQueryString()%></TD></TR>
</Table>
<br>
<br>

<%--------------------------------%>
<%-- 3. HTTP HEADER INFORMATION --%>
<%--------------------------------%>
<Table border=1>
<th colspan=2>HTTP Header information</th>	
<% 
	Enumeration headerNamesDebug = request.getHeaderNames();
	while(headerNamesDebug.hasMoreElements())
    {
		String headerNameDebug = (String)headerNamesDebug.nextElement();
%>
	<TR><TD> <%=headerNameDebug %>  <%=(String) request.getHeader(headerNameDebug) %>
<%    
    }
%>
</Table>
<br>
<br>

<%---------------------------------------%>
<%-- 4. REQUEST ATTRIBUTES INFORMATION --%>
<%---------------------------------------%>
<% 
	Enumeration keysDebug = request.getAttributeNames();
	if (keysDebug.hasMoreElements())
	{
%>
<Table border=1>
<th colspan=2>Request Attributes information</th>	
<%

		while(keysDebug.hasMoreElements())
		{
			String keyDebug = (String) keysDebug.nextElement();
%>
			<TR><TD><%=keyDebug%> </TD><TD> <%=request.getAttribute(keyDebug)%></TD></TR>
<% 
		}
%>
</Table>
<%
	}
%>
<br>
<br>

<%----------------------------%>
<%-- 5. SESSION INFORMATION --%>
<%----------------------------%>
<Table border=1>
	<th colspan=2>Session Information</th>
	<TR><TD>ID</TD><TD> <%=session.getId() %></TD></TR>
	<TR><TD>IsNew?</TD><TD> <%=session.isNew() %></TD></TR>
	<TR><TD>Creation Time</TD><TD> <%=session.getCreationTime() %></TD></TR>
	<TR><TD>Last Access Time</TD><TD> <%=session.getLastAccessedTime() %></TD></TR>
	<TR><TD>Max Inactive Interval</TD><TD> <%=session.getMaxInactiveInterval() %></TD></TR>
	<TR><TD>Session Context</TD><TD> <%=session.getSessionContext() %></TD></TR>
<%
Date date = new Date(session.getCreationTime());
%>
	<TR><TD>Session DATE</TD><TD> <%=date.toString() %></TD></TR>
	<TR>
		<TD>Data:</TD>
		<TD>
			<table border=1>
<%
	Enumeration sessionHeadersDebug = session.getAttributeNames();
	while(sessionHeadersDebug.hasMoreElements())
	{
		String sessionHeaderDebug = (String) sessionHeadersDebug.nextElement();
		Object sessionValueDebug = session.getAttribute(sessionHeaderDebug);		
	%>
				<TR><TD> <%=sessionHeaderDebug %> </TD><TD> <%=sessionValueDebug.toString() %></TD></TR>
<%    
    }
%>
			</table>
		</TD>
	</TR>
</Table>
<br>
<br>

<%---------------------------%>
<%-- 6. SYSTEM INFORMATION --%>
<%---------------------------%>
<Table border=1>
		<th colspan=2>System Information</th>
<%
	Enumeration propsDebug = System.getProperties().propertyNames();
	while(propsDebug.hasMoreElements())
	{
		String propKeyDebug = (String)propsDebug.nextElement();
		String propValueDebug = (String) System.getProperty(propKeyDebug);
%>
<TR><TD> <%=propKeyDebug %> </TD><TD> <%=propValueDebug %></TD></TR>
<%    
	}
%>
</Table>
<br>
<br>
<%-------------------------%>
<%-- 7. LDAP INFORMATION --%>
<%-------------------------%>
<%
if(session.getAttribute("ldap")!=null)
{
	Hashtable ldapDebug = (Hashtable) session.getAttribute("ldap");
	if(!ldapDebug.isEmpty())
	{
%>
		<Table border=1>
		<th colspan=2>LDAP Information</th>
<%
		Enumeration ldapKeysDebug = ldapDebug.keys();
		while(ldapKeysDebug.hasMoreElements())
		{
			String ldapKeyDebug = (String)ldapKeysDebug.nextElement();
			String ldapValueDebug = (String) ldapDebug.get(ldapKeyDebug);
%>
		<TR><TD> <%=ldapKeyDebug %> </TD><TD> <%=ldapValueDebug %></TD></TR>
<%    
    	}
%>
		</Table>
<%   
	}
}
%>
<br>
<br>
</fieldset>
</hr>
<br>
<br>
<br>
<br>

